{% load static humanize %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单支付 - 智淘go</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        /* 继承商品详情页样式变量 */
        :root {
            --primary: #FF6B6B;
            --secondary: #4ECDC4;
            --text-dark: #2D3436;
            --text-light: #636E72;
            --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }

        /* 基础样式 */
        body {
            font-family: 'Helvetica Neue', Arial, 'Microsoft YaHei', sans-serif;
            background: url('https://pic2.zhimg.com/v2-86ffa1ad12c00587d5cb6f9bd362578a_r.jpg?source=1940ef5c') no-repeat center center fixed;
            margin: 0;
            padding: 2rem;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        /* 支付容器 */
        .payment-card {
            background: white;
            padding: 3rem;
            border-radius: 16px;
            box-shadow: var(--shadow);
        }

        /* 商品信息 */
        .product-header {
            display: flex;
            align-items: center;
            gap: 2rem;
            margin-bottom: 3rem;
        }

        .product-image {
            width: 180px;
            height: 180px;
            object-fit: cover;
            border-radius: 12px;
        }

        /* 表单样式 */
        .form-section {
            display: grid;
            gap: 2rem;
        }

        .form-group label {
            display: block;
            margin-bottom: 0.8rem;
            color: var(--text-dark);
            font-weight: 500;
        }

        .form-input {
            width: 100%;
            padding: 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 1rem;
        }

        /* 支付按钮 */
        .submit-btn {
            background: var(--primary);
            color: white;
            padding: 1.5rem;
            border: none;
            border-radius: 8px;
            font-size: 1.1rem;
            cursor: pointer;
            transition: opacity 0.3s;
            width: 100%;
        }

        .submit-btn:hover {
            opacity: 0.9;
        }
    </style>
</head>
<body>
    <div class="container">
        <a href="{% url 'product_list' %}" style="display: inline-block; margin-bottom: 2rem;">
            <i class="fas fa-arrow-left"></i>
            返回商品
        </a>

        <div class="payment-card">
            <!-- 商品信息 -->
            <div class="product-header">
                <img src="{{ product.image.url }}"
                     class="product-image"
                     alt="{{ product.name }}">
                <div>
                    <h1>{{ product.name }}</h1>
                    <p style="font-size: 1.5rem; color: var(--primary);">
                        ¥{{ product.price|intcomma }}
                    </p>
                </div>
            </div>

            <!-- 支付表单 -->
            <form class="form-section" onsubmit="return handlePayment(event)">
                <div class="form-group">
                    <label>收货人姓名</label>
                    <input type="text" class="form-input" required>
                </div>

                <div class="form-group">
                    <label>联系电话</label>
                    <input type="tel" class="form-input" pattern="\d{11}" required>
                </div>

                <div class="form-group">
                    <label>详细地址</label>
                    <input type="text" class="form-input" required>
                </div>

                <button type="submit" class="submit-btn">
                    <i class="fas fa-credit-card"></i>
                    确认支付
                </button>
            </form>
        </div>
    </div>

<script>
    function handlePayment(e) {
        e.preventDefault();

        // 简单表单验证
        const inputs = document.querySelectorAll('[required]');
        let isValid = true;

        inputs.forEach(input => {
            if (!input.value.trim()) {
                input.style.borderColor = 'var(--primary)';
                isValid = false;
            } else {
                input.style.borderColor = '#e2e8f0';
            }
        });

        if (isValid) {
            // 创建弹窗元素
            const modal = document.createElement('div');
            modal.style = `
                position: fixed;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                background: white;
                padding: 2rem;
                border-radius: 12px;
                box-shadow: 0 10px 20px rgba(0,0,0,0.2);
                text-align: center;
                z-index: 1000;
            `;

            modal.innerHTML = `
                <h2 style="color: var(--primary); margin-bottom: 1rem;">
                    <i class="fas fa-check-circle"></i>
                    支付成功！
                </h2>
                <p>商品将在3个工作日内发货</p>
                <button onclick="this.parentElement.remove()"
                        style="margin-top: 1.5rem;
                               padding: 0.8rem 2rem;
                               background: var(--secondary);
                               color: white;
                               border: none;
                               border-radius: 8px;
                               cursor: pointer;">
                    关闭
                </button>
            `;

            // 添加半透明背景
            const overlay = document.createElement('div');
            overlay.style = `
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(0,0,0,0.5);
                z-index: 999;
            `;

            document.body.appendChild(overlay);
            document.body.appendChild(modal);

            // 3秒后自动关闭
            setTimeout(() => {
                modal.remove();
                overlay.remove();
            }, 3000);
        }
    }
</script>
</body>
</html>